import 'package:cbec_app/app.dart';
import 'package:cbec_app/entity/signIn/sign_in_prize_bean.dart';
import 'package:flutter/material.dart';
import 'package:flutter_popup/flutter_popup.dart';

import '../../../utils/Tools.dart';

class SignInResultDialogWidget extends StatefulWidget {
  final Function? onPress;
  final List<SignInPrizeBean?>? prizeList;

  SignInResultDialogWidget({super.key, required this.prizeList, this.onPress});

  @override
  _SignInResultDialogWidgetState createState() =>
      _SignInResultDialogWidgetState();
}

class _SignInResultDialogWidgetState extends State<SignInResultDialogWidget>
    with TickerProviderStateMixin {
  TabController? tabCtrLottery;
  bool isAll = true;

  @override
  void initState() {
    super.initState();
    tabCtrLottery = TabController(length: 2, vsync: this);
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Stack(
            alignment: Alignment.center,
            children: [
              Image.asset("assets/images/ic_sign_in_dialog_bg.png"),
              Container(
                width: Screen.width,
                height: 100,
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: <Widget>[
                    // Column(
                    //   children: [
                        Text(
                          '已经到账',
                          style: TextStyle(
                              color: Tools.fromHex('#C07516'), fontSize: 20),
                        ),
                    Container(
                      width: 200,
                        height: 60,
                        // padding: EdgeInsets.only(left: 8.w, right: 8.w),
                        child: ListView.builder(
                          itemCount: widget.prizeList?.length ?? 0,
                          itemBuilder: (context, index) {
                            return   _itemLayout(widget!.prizeList![index]!);
                          },
                        )),
                        // _ItemLayout(),
                      // ],
                    // ),
                  ],
                ),
              ),
              Container(
                margin: EdgeInsets.only(top: 120),
                child: GestureDetector(
                  onTap: () {
                    Navigator.pop(context);
                    widget.onPress?.call();
                  },
                  child: Card(
                    color: Colors.transparent,
                    shadowColor: Colors.transparent,
                    child: Container(
                      width: 130,
                      height: 40,
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(20), // 设置圆角
                        gradient: LinearGradient(
                          begin: Alignment.topCenter,
                          end: Alignment.bottomCenter,
                          colors: [
                            Tools.fromHex('#FFDA87'),
                            Tools.fromHex('#D7A128'),
                          ],
                        ),
                      ),
                      padding:
                          EdgeInsets.symmetric(horizontal: 10, vertical: 4),
                      child: Text(
                        '开心收下',
                        style: TextStyle(
                            color: Colors.white,
                            fontWeight: FontWeight.w500,
                            fontSize: 16),
                      ),
                    ),
                  ),
                ),
              )
            ],
          ),
          GestureDetector(
            onTap: () {
              Navigator.pop(context);
              widget.onPress?.call();
            },
            child: Image.asset(
              "assets/images/close.png",
              color: Colors.white,
              width: 20,
            ),
          )
        ],
      ),
    );
  }

  Widget _itemLayout(SignInPrizeBean e){
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Text(
          '+',
          style: TextStyle(color: Tools.fromHex('#C07516'), fontSize: 14),
        ),
        Text(
          '${e?.prizeName ?? ""}*${(e == null || e.total == null)? '' : e?.total}',
          style: TextStyle(color: Tools.fromHex('#C07516'), fontSize: 14),
        )
      ],
    );
  }
}
